import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by hansheng11 on 2019/12/10 16:48.
 */
public class 第11题_盛最多水的容器 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (input.hasNext()) {
            String s = input.next();
            String[] split = s.split(",");
            int[] ints = Arrays.stream(split).mapToInt(Integer::valueOf).toArray();
            maxArea(ints);
        }
    }

    public static int maxArea(int[] height) {
        int i = 0;
        int j = height.length - 1;
        int max = 0;
        while (i < j) {
            max = Math.max(max, (j - i) * Math.min(height[i], height[j]));
            if (height[i] > height[j]) {
                j--;
            } else {
                i++;
            }
        }
        return max;
    }
}
